package br.com.musclebook.bean;

import java.io.ByteArrayInputStream;
import java.io.Serializable;

import javax.faces.bean.SessionScoped;
import javax.inject.Named;

import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;

@Named
@SessionScoped
public class SessionInfoBean implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long userId;
    private String userFirstName;
    private String userLastName;
    private byte[] userImage;

    public boolean isUserAuthenticated() {
	return this.userId != null;
    }
    
    public StreamedContent getUserImage() {
	if (this.userId == null || this.userImage == null)
	    return null;

	return new DefaultStreamedContent(new ByteArrayInputStream(this.userImage), "image/jpeg");
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUserFirstName() {
        return userFirstName;
    }

    public void setUserFirstName(String userFirstName) {
        this.userFirstName = userFirstName;
    }

    public String getUserLastName() {
        return userLastName;
    }

    public void setUserLastName(String userLastName) {
        this.userLastName = userLastName;
    }

    public void setUserImage(byte[] userImage) {
        this.userImage = userImage;
    }

    

}
